home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d11 / nansi22b.arc / NANSI_I.ASM < prev    next >
Assembly Source File  |  1987-12-03  |  3KB  |  113 lines

  1.  
  2.     page    66, 132
  3. ;------ nansi_i.asm ----------------------------------------------
  4. ; Contains code only needed at initialization time.
  5. ; (C) 1986 Daniel Kegel
  6. ; May be distributed for educational and personal use only
  7. ;-----------------------------------------------------------------
  8.  
  9.     include nansi_d.asm        ; definitions
  10.  
  11.                     ; to nansi.asm
  12.     public    dosfn0
  13.  
  14.                     ; from nansi.asm
  15.     extrn    break_handler:near
  16.     extrn    int_29:near
  17.     IF    takeBIOS
  18.         extrn   new_vid_bios:near
  19.         extrn   old_vid_bios:dword
  20.     ENDIF
  21.     extrn    req_ptr:dword
  22.     extrn    xlate_tab_ptr:word
  23.  
  24.                     ; from nansi_p.asm
  25.     extrn    param_buffer:word    ; adr of first byte free for params
  26.     extrn    param_end:word        ; adr of last byte used for params
  27.     extrn    redef_end:word        ; adr of last used byte for redefs
  28.  
  29.  
  30. code    segment byte public 'CODE'
  31.     assume    cs:code, ds:code
  32.  
  33. ;-------- dos function # 0 : init driver ---------------------
  34. ; Initializes device driver interrupts and buffers, then
  35. ; passes ending address of the device driver to DOS.
  36. ; Since this code is only used once, the buffer can be set up on top
  37. ; of it to save RAM.
  38.  
  39. dosfn0    proc    near
  40.                     ; Install BIOS keyboard break handler.
  41.     xor    ax, ax
  42.     mov    ds, ax
  43.     mov    bx, 6Ch
  44.     mov    word ptr [BX],offset break_handler
  45.     mov    [BX+02], cs
  46.                     ; Install INT 29 quick putchar.
  47.     mov    bx, 0a4h
  48.     mov    word ptr [bx], offset int_29
  49.     mov    [bx+2], cs
  50.     IF    takeBIOS
  51.                     ; Install INT 10h video bios replacement.
  52.         mov     bx, 40h
  53.         mov     ax, [bx]
  54.         mov     word ptr cs:old_vid_bios, ax
  55.         mov     ax, [bx+2]
  56.         mov     word ptr cs:old_vid_bios[2], ax
  57.         mov     word ptr [bx], offset new_vid_bios
  58.         mov     word ptr [bx+2], cs
  59.     ENDIF
  60.  
  61.     push    cs
  62.     pop    ds
  63.     push    cs
  64.     pop    es            ; es=cs so we can use stosb
  65.     cld                ; make sure stosb increments di
  66.  
  67.                     ; Calculate addresses of start and end of parameter/redef buffer.
  68.                     ; The buffer occupies the same area of memory as this code!
  69.                     ; ANSI parameters are accumulated at the lower end, and
  70.                     ; keyboard redefinitions are stored at the upper end; the variable
  71.                     ; param_end is the last byte used by params (changes as redefs added);
  72.                     ; redef_end is the last word used by redefinitions.
  73.     mov    di, offset dosfn0
  74.     mov    param_buffer, di
  75.     add    di, 512
  76.     mov    param_end, di        ; addr of last byte in free area
  77.     inc    di
  78.  
  79.                     ; Build the default redefinition table:
  80.                     ;    control-printscreen -> control-P
  81.                     ; (Must be careful not to write over ourselves here!)
  82.     mov    al, 16            ; control P
  83.     stosb
  84.     mov    ax, 7200h        ; control-printscreen
  85.     stosw
  86.     mov    ax, 1            ; length field
  87.     mov    redef_end, di        ; address of last used word in table
  88.     stosw
  89.  
  90.                     ; Build a 1:1 output character translation table.
  91.                     ; It is 256 bytes long, starts just after the param/redef buffer,
  92.                     ; and is the last thing in the initialized device driver.
  93.     mov    xlate_tab_ptr, di
  94.     xor    ax, ax
  95. init_loop:
  96.     stosb
  97.     inc    al
  98.     jnz    init_loop
  99.  
  100.     xor    ax, ax
  101.                     ; Return ending address of this device driver.
  102.                     ; Status is in AX.
  103.     lds    si, req_ptr
  104.     mov    word ptr [si+0Eh], di
  105.     mov    [si+10h], cs
  106.                     ; Return exit status in ax.
  107.     ret
  108.  
  109. dosfn0    endp
  110.  
  111. code    ends
  112.     end                ; of nansi_i.asm
  113. [s